clear
set more      off
set varabbrev off
set gr        off
set linesize 255

/* INPUTS */

local in_uirams 	"/data2/cedsei/data2/search_ui_rams_ww"


/* OUTPUTS */

local out_analysis 	"/data2/cedsei/data2/analysis_sample_ww"

*cd "/data2/cedsei/data2"

local co = 1 
********************************************************************************

clear 
use `in_uirams'

keep if inrange(daily_wage_normalized,-300,300)
keep if date<ym(2015,9) & date>ym(2005,1)
count 
gen year = year(dofm(date))
tab year 
count if mi(earnings_month_6)

foreach num of numlist 0(1)6 {
	gen work_`num'  = cond(earnings_month_`num'>0,cond(pes_se_`num'==0,1,0),0)
}

foreach num of numlist 0(1)6 {
	local kk = `num' -1
	gen workabs_`num' = cond(work_`num'==1,1,0)
	if `num'>0 {
		replace workabs_`num' = 1 if workabs_`kk'==1 
	}
}
drop working_* 

save `out_analysis', replace 











